wall. If the shot hits a brick wall, the wall would disappear (i.e., in this turn). Well, given the description of a maps, the positions of your tank and the target, how many turns would you take at least to Arrive there?
Input the input consists of several test cases. The first line of all test case contains, integers m and n (2
Output for each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.
Sample Input
3 4
ybeb
EERE
description of a maps, the positions of your tank and the target, how many turns would you take at least to Arrive there? Enter the input consists of several test cases. The first line of all test case contains, integers m and n (2 Output for each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.Sample input
3 4
ybeb
EERE
sste
0 0Sample output
8
Wide Search (BFS) + priority q
turn). Well, given the description of a maps, the positions of your tank and the target, how many turns would you take at least to Arrive there? Enter the input consists of several test cases. The first line of all test case contains, integers m and n (2 Output for each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.Sample input
3 4
ybeb
EERE
sste
0 0Sample output
8
Analysi
direction, until it go out of the the map or hit a wall. If the shot hits a brick wall, the wall would disappear (i.e., in this turn). Well, given the description of a maps, the positions of your tank and the target, how many turns would you take at least to Arrive there?
Input the input consists of several test cases. The first line of all test case contains, integers m and n (2
Output for each test case, please output the turns to least in a separate line. If you can ' t arrive at the target
wall. If the shot hits a brick wall, the wall would disappear (i.e., in this turn). Well, given the description of a maps, the positions of your tank and the target, how many turns would you take at least to Arrive there?
Input the input consists of several test cases. The first line of all test case contains, integers m and n (2
Output for each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.
Sample Input
3 4
ybeb
EERE
wall. If the shot hits a brick wall, the wall would disappear (i.e., in this turn). Well, given the description of a maps, the positions of your tank and the target, how many turns would you take at least to Arrive there?
Input the input consists of several test cases. The first line of all test case contains, integers m and n (2
Output for each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.
Sample Input
3 4
ybeb
EERE
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.